﻿<Window x:Class="Launchbar.WindowSettings" x:ClassModifier="internal"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Properties="clr-namespace:Launchbar.Properties"
        xmlns:lb="clr-namespace:Launchbar"
        xmlns:Diagnostics="clr-namespace:System.Diagnostics;assembly=System"
        xmlns:Shapes="clr-namespace:Launchbar.Shapes"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        Title="Launchbar Settings"
        MinHeight="550" MinWidth="400" Height="600" Width="450"
        Icon="Resources/Settings.ico"
        DataContext="{Binding RelativeSource={x:Static RelativeSource.Self}}"
        Hyperlink.RequestNavigate="hyperlinkRequestNavigate">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TabControl>
            <TabControl.Resources>
                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
                    <Setter Property="VerticalAlignment" Value="Center"/>
                </Style>
            </TabControl.Resources>
            <TabItem Header="General">
                <StackPanel>
                    <FrameworkElement.Resources>
                        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
                            <Setter Property="VerticalAlignment" Value="Center"/>
                        </Style>
                        <Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource {x:Type GroupBox}}">
                            <Setter Property="Margin" Value="3"/>
                        </Style>
                    </FrameworkElement.Resources>

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <FrameworkElement.Resources>
                            <Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource {x:Type GroupBox}}">
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="VerticalAlignment" Value="Top"/>
                            </Style>
                            <Style TargetType="{x:Type StackPanel}">
                                <Setter Property="HorizontalAlignment" Value="Center"/>
                                <Setter Property="VerticalAlignment" Value="Center"/>
                                <Setter Property="Margin" Value="3"/>
                            </Style>
                            <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
                                <Setter Property="HorizontalAlignment" Value="Center"/>
                                <Setter Property="Margin" Value="3"/>
                            </Style>
                            <Style TargetType="{x:Type Shapes:ShapeMonitor}">
                                <Setter Property="Width" Value="40"/>
                                <Setter Property="Height" Value="40"/>
                                <Setter Property="Margin" Value="10"/>
                            </Style>
                        </FrameworkElement.Resources>

                        <GroupBox Header="Layout (primary screen)">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>

                                <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
                                    <TextBlock Text="Left"/>
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarLeft}"/>
                                </StackPanel>

                                <StackPanel Grid.Row="0" Grid.Column="1">
                                    <TextBlock Text="Top"/>
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarTop}"/>
                                </StackPanel>

                                <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarRight}"/>
                                    <TextBlock Text="Right"/>
                                </StackPanel>

                                <StackPanel Grid.Row="2" Grid.Column="1">
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarBottom}"/>
                                    <TextBlock Text="Bottom"/>
                                </StackPanel>

                                <Shapes:ShapeMonitor Grid.Row="1" Grid.Column="1"/>
                            </Grid>
                        </GroupBox>

                        <GroupBox Header="Layout (secondary screen)">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>

                                <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
                                    <TextBlock Text="Left"/>
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarLeftSecondary}"/>
                                </StackPanel>

                                <StackPanel Grid.Row="0" Grid.Column="1">
                                    <TextBlock Text="Top"/>
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarTopSecondary}"/>
                                </StackPanel>

                                <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarRightSecondary}"/>
                                    <TextBlock Text="Right"/>
                                </StackPanel>

                                <StackPanel Grid.Row="2" Grid.Column="1">
                                    <CheckBox IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=BarBottomSecondary}"/>
                                    <TextBlock Text="Bottom"/>
                                </StackPanel>

                                <Shapes:ShapeMonitor Grid.Row="1" Grid.Column="1"/>
                            </Grid>
                        </GroupBox>
                    </StackPanel>

                    <GroupBox Header="Design">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="3"/>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="3"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="3"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Bar opacity:"/>
                            <Slider Grid.Column="2" Grid.Row="0"
                                    Minimum="0.01" Maximum="1" SmallChange="0.01" LargeChange="0.1"
                                    IsSnapToTickEnabled="True" TickFrequency="0.01"
                                    Value="{Binding Source={x:Static Properties:Settings.Default}, Path=BarOpacity}"/>
                            <TextBlock Grid.Column="4" Grid.Row="0"
                                       Text="{Binding Source={x:Static Properties:Settings.Default}, Path=BarOpacity, Mode=OneWay, StringFormat='{}{0:f2}'}"/>

                            <TextBlock Grid.Column="0" Grid.Row="2" Text="Menu scale:"/>
                            <Slider Grid.Column="2" Grid.Row="2"
                                    Minimum="1" Maximum="2" SmallChange="0.01" LargeChange="0.1"
                                    IsSnapToTickEnabled="True" TickFrequency="0.01"
                                    Value="{Binding Source={x:Static Properties:Settings.Default}, Path=ContextMenuScale}"/>
                            <TextBlock Grid.Column="4" Grid.Row="2"
                                       Text="{Binding Source={x:Static Properties:Settings.Default}, Path=ContextMenuScale, Mode=OneWay, StringFormat='{}{0:f2}x'}"/>
                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Options">
                        <Grid Margin="3">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <FrameworkElement.Resources>
                                <TextDecorationCollection x:Key="HasToolTipDecoration">
                                    <TextDecoration>
                                        <TextDecoration.Pen>
                                            <Pen Brush="#60000000">
                                                <Pen.DashStyle>
                                                    <DashStyle Dashes="2,4"/>
                                                </Pen.DashStyle>
                                            </Pen>
                                        </TextDecoration.Pen>
                                    </TextDecoration>
                                </TextDecorationCollection>
                            </FrameworkElement.Resources>
                            
                            <CheckBox Grid.Row="1" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=QuickLaunch, Mode=TwoWay}"
                                      VerticalContentAlignment="Center">
                                <TextBlock>
                                    <TextBlock.Inlines>
                                        <Run TextDecorations="{StaticResource HasToolTipDecoration}" Text="QuickLaunch"
                                             ToolTipService.ShowDuration="{x:Static s:Int32.MaxValue}"
                                             ToolTip="Allows you to quickly launch the first menu entry by pressing the left mouse button directly after opening the Launchbar menu (right click)."/>
                                    </TextBlock.Inlines>
                                </TextBlock>
                            </CheckBox>
                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Tips">
                        <StackPanel Margin="3">
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <TextBlock Text="&#8226;"/>
                                </BulletDecorator.Bullet>
                                <TextBlock TextWrapping="Wrap" Margin="3,0,0,0" Text="You can access Launchbar while this dialog is open, to preview any changes."/>
                            </BulletDecorator>
                            <BulletDecorator>
                                <BulletDecorator.Bullet>
                                    <TextBlock Text="&#8226;"/>
                                </BulletDecorator.Bullet>
                                <TextBlock TextWrapping="Wrap" Margin="3,0,0,0" Text="You can always open the settings dialog by pressing CTRL+S in Launchbar."/>
                            </BulletDecorator>
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </TabItem>

            <TabItem Header="Menu">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <GroupBox Grid.ColumnSpan="2" Header="Details"
                              IsEnabled="{Binding Path=IsMenuEntryAdvanced, Mode=OneWay}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="3"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="3"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="3"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="10"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="3"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.RowSpan="7" VerticalAlignment="Center">
                                <Button Width="45" Height="45" Margin="0,0,0,10"
                                        Click="buttonChooseIconClick">
                                    <Image Width="32" Height="32"
                                           Source="{Binding Path=SelectedMenuEntryAdvanced.Icon, Mode=OneWay}"/>
                                </Button>

                                <Button HorizontalAlignment="Center" VerticalAlignment="Center"
                                        Click="buttonClearIconClick">
                                    <Button.Style>
                                        <Style TargetType="{x:Type Button}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=SelectedMenuEntryAdvanced.IconPath, Mode=OneWay}" Value="{x:Null}">
                                                    <Setter Property="IsEnabled" Value="false"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Button.Style>
                                    <Shapes:ShapeDelete Width="16" Height="16"/>
                                </Button>
                            </StackPanel>

                            <TextBlock Grid.Column="2" Grid.Row="0" Text="Name:"/>
                            <TextBox x:Name="textBoxName" x:FieldModifier="private"
                                     Grid.Column="4" Grid.Row="0"
                                     Text="{Binding Path=SelectedMenuEntryAdvanced.Text}"
                                     IsEnabled="{Binding Path=IsMenuEntryAdvanced, Mode=OneWay}"/>

                            <TextBlock Grid.Column="2" Grid.Row="2" Text="Path:"/>
                            <Grid Grid.Column="4" Grid.Row="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBox Text="{Binding Path=SelectedProgram.Path, UpdateSourceTrigger=PropertyChanged}"
                                         IsEnabled="{Binding Path=IsProgram, Mode=OneWay}">
                                    <TextBox.Style>
                                        <Style TargetType="{x:Type TextBox}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=IsProgram, Mode=OneWay}" Value="true">
                                                    <Setter Property="Background" Value="Tomato"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Path=SelectedProgram.IsValidPath, Mode=OneWay}" Value="true">
                                                    <Setter Property="Background" Value="Khaki"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Path=SelectedProgram.IsValidFile, Mode=OneWay}" Value="true">
                                                    <Setter Property="Background" Value="YellowGreen"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBox.Style>
                                </TextBox>
                                <Button Grid.Column="1" Margin="3,0,0,0"
                                        ToolTip="Browse for a file or directory."
                                        Click="buttonBrowseClick">
                                    <TextBlock Text="..."/>
                                </Button>
                            </Grid>

                            <TextBlock Grid.Column="2" Grid.Row="4" Text="Arguments:"/>
                            <TextBox Grid.Column="4" Grid.Row="4"
                                     Text="{Binding Path=SelectedProgram.Arguments}"
                                     IsEnabled="{Binding Path=IsProgram, Mode=OneWay}"/>

                            <TextBlock Grid.Column="2" Grid.Row="6" Text="Priority:"/>
                            <ComboBox Grid.Column="4" Grid.Row="6"
                                      MinWidth="150"
                                      HorizontalAlignment="Left"
                                      SelectedItem="{Binding Path=SelectedProgram.Priority}"
                                      IsEnabled="{Binding Path=IsProgram, Mode=OneWay}">
                                <ComboBox.ItemsSource>
                                    <x:Array Type="{x:Type Diagnostics:ProcessPriorityClass}">
                                        <x:Static Member="Diagnostics:ProcessPriorityClass.Idle"/>
                                        <x:Static Member="Diagnostics:ProcessPriorityClass.BelowNormal"/>
                                        <x:Static Member="Diagnostics:ProcessPriorityClass.Normal"/>
                                        <x:Static Member="Diagnostics:ProcessPriorityClass.AboveNormal"/>
                                        <x:Static Member="Diagnostics:ProcessPriorityClass.High"/>
                                    </x:Array>
                                </ComboBox.ItemsSource>
                            </ComboBox>
                        </Grid>
                    </GroupBox>

                    <TreeView Grid.Column="0" Grid.Row="1" AllowDrop="True" Drop="treeViewDrop"
                              SelectedItemChanged="treeViewEntriesSelectedItemChanged"
                              ItemsSource="{Binding Source={x:Static Properties:Settings.Default}, Path=Menu.Entries}"
                              Margin="0,3,3,0">
                        <FrameworkElement.Resources>
                            <!--TreeViewItem templates-->
                            <ControlTemplate x:Key="templateProgram">
                                <StackPanel Orientation="Horizontal" MinWidth="150">
                                    <Image Style="{StaticResource StyleIcon}"
                                           Source="{Binding Path=Icon, Mode=OneWay}"/>
                                    <TextBlock Text="{Binding Path=Text, Mode=OneWay}"
                                               Margin="3,0,0,0"  VerticalAlignment="Center"/>
                                </StackPanel>
                            </ControlTemplate>
                            <ControlTemplate x:Key="templateStandardSubmenu">
                                <StackPanel Orientation="Horizontal" MinWidth="150">
                                    <Shapes:ShapeFolder Style="{StaticResource StyleIcon}"
                                                        IsOpen="{Binding Path=IsExpanded, Mode=OneWay}"/>
                                    <TextBlock Text="{Binding Path=Text, Mode=OneWay}" VerticalAlignment="Center"/>
                                </StackPanel>
                            </ControlTemplate>
                            <ControlTemplate x:Key="templateSeparator">
                                <Separator Width="150" Height="10"/>
                            </ControlTemplate>
                            <ControlTemplate x:Key="templateSettings">
                                <StackPanel Orientation="Horizontal" MinWidth="150">
                                    <Image Source="{StaticResource imageSettings}" Style="{StaticResource StyleIcon}"/>
                                    <TextBlock Text="Settings" VerticalAlignment="Center"/>
                                </StackPanel>
                            </ControlTemplate>
                            <ControlTemplate x:Key="templateExit">
                                <StackPanel Orientation="Horizontal" MinWidth="150">
                                    <Shapes:ShapeClose Width="20" Height="20" Margin="2,3"/>
                                    <TextBlock Text="Exit" VerticalAlignment="Center"/>
                                </StackPanel>
                            </ControlTemplate>

                            <lb:ElementCreator x:Key="creator"/>

                            <!--TreeViewItem styles-->
                            <Style x:Key="styleMenuEntry" TargetType="{x:Type TreeViewItem}">
                                <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
                            </Style>
                            <Style x:Key="styleProgram" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource styleMenuEntry}">
                                <Setter Property="Header" Value="{Binding Converter={StaticResource creator},
                                                                          ConverterParameter={StaticResource templateProgram}, Mode=OneTime}"/>
                            </Style>
                            <Style x:Key="styleSubmenu" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource styleProgram}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IconType}" Value="{x:Static lb:IconType.Default}">
                                        <Setter Property="Header" Value="{Binding Converter={StaticResource creator},
                                                                          ConverterParameter={StaticResource templateStandardSubmenu}, Mode=OneTime}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                                <Setter Property="ItemsSource" Value="{Binding Path=MenuEntries, Mode=OneWay}"/>
                                <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>
                            </Style>
                            <Style x:Key="styleSearator" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource styleMenuEntry}">
                                <Setter Property="Header" Value="{Binding Converter={StaticResource creator},
                                                                          ConverterParameter={StaticResource templateSeparator}, Mode=OneTime}"/>
                            </Style>
                            <Style x:Key="styleSettings" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource styleMenuEntry}">
                                <Setter Property="Header" Value="{Binding Converter={StaticResource creator},
                                                                          ConverterParameter={StaticResource templateSettings}, Mode=OneTime}"/>
                            </Style>
                            <Style x:Key="styleExit" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource styleMenuEntry}">
                                <Setter Property="Header" Value="{Binding Converter={StaticResource creator},
                                                                          ConverterParameter={StaticResource templateExit}, Mode=OneTime}"/>
                            </Style>
                        </FrameworkElement.Resources>

                        <TreeView.ItemContainerStyleSelector>
                            <lb:MenuItemStyleSelector ProgramStyle="{StaticResource styleProgram}"
                                                             SubmenuStyle="{StaticResource styleSubmenu}"
                                                             SeparatorStyle="{StaticResource styleSearator}"
                                                             SettingsStyle="{StaticResource styleSettings}"
                                                             ExitStyle="{StaticResource styleExit}"/>
                        </TreeView.ItemContainerStyleSelector>
                    </TreeView>

                    <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">
                        <FrameworkElement.Resources>
                            <Style x:Key="styleButton" TargetType="{x:Type Button}">
                                <Setter Property="Margin" Value="3"/>
                            </Style>
                            <Style x:Key="styleDisableOnNull" TargetType="{x:Type Button}" BasedOn="{StaticResource styleButton}" >
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=SelectedMenuEntry, Mode=OneWay}" Value="{x:Null}">
                                        <Setter Property="IsEnabled" Value="false"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                            <Style x:Key="styleIconPlus" TargetType="{x:Type Shapes:ShapePlus}">
                                <Setter Property="Width" Value="12"/>
                                <Setter Property="Height" Value="12"/>
                                <Setter Property="HorizontalAlignment" Value="Right"/>
                                <Setter Property="VerticalAlignment" Value="Bottom"/>
                            </Style>
                        </FrameworkElement.Resources>

                        <Button ToolTip="Move the selected entry upwards."
                                Click="buttonMoveUpClick" Style="{StaticResource styleDisableOnNull}">
                            <Shapes:ShapeNext Style="{StaticResource StyleIcon}">
                                <Shapes:ShapeNext.LayoutTransform>
                                    <RotateTransform Angle="180"/>
                                </Shapes:ShapeNext.LayoutTransform>
                            </Shapes:ShapeNext>
                        </Button>

                        <Button ToolTip="Add a program."
                                Click="buttonAddProgramClick" Style="{StaticResource styleButton}">
                            <Grid>
                                <Shapes:ShapeApplication Style="{StaticResource StyleIcon}"/>
                                <Shapes:ShapePlus Style="{StaticResource styleIconPlus}"/>
                            </Grid>
                        </Button>

                        <Button ToolTip="Add a sumenu."
                                Click="buttonAddSubmenuClick" Style="{StaticResource styleButton}">
                            <Grid>
                                <Shapes:ShapeFolder IsOpen="True" Style="{StaticResource StyleIcon}"/>
                                <Shapes:ShapePlus Style="{StaticResource styleIconPlus}"/>
                            </Grid>
                        </Button>

                        <Button ToolTip="Add a separator."
                                Click="buttonAddSeparatorClick" Style="{StaticResource styleButton}">
                            <Grid>
                                <Path Style="{StaticResource StyleIcon}" Data="M2,12 h20" StrokeThickness="3">
                                    <Path.Stroke>
                                        <LinearGradientBrush>
                                            <GradientStop Color="Transparent" Offset="0"/>
                                            <GradientStop Color="Silver" Offset="0.1"/>
                                            <GradientStop Color="Black" Offset="0.5"/>
                                            <GradientStop Color="Silver" Offset="0.9"/>
                                            <GradientStop Color="Transparent" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Path.Stroke>
                                </Path>
                                <Shapes:ShapePlus Style="{StaticResource styleIconPlus}"/>
                            </Grid>
                        </Button>

                        <Button ToolTip="Add an entry to open the Launchbar settings dialog."
                                Click="buttonAddSettingsClick" Style="{StaticResource styleButton}">
                            <Grid>
                                <Image Source="{StaticResource imageSettings}" Style="{StaticResource StyleIcon}"/>
                                <Shapes:ShapePlus Style="{StaticResource styleIconPlus}"/>
                            </Grid>
                        </Button>

                        <Button ToolTip="Add an entry to shutdown the application."
                                Click="buttonAddExitClick" Style="{StaticResource styleButton}">
                            <Grid>
                                <Shapes:ShapeClose Margin="2" Width="20" Height="20"
                                                   IsHover="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}"/>
                                <Shapes:ShapePlus Style="{StaticResource styleIconPlus}"/>
                            </Grid>
                        </Button>

                        <Button ToolTip="Delete the currently selected entry."
                                Click="buttonDeleteClick" Style="{StaticResource styleDisableOnNull}">
                            <Shapes:ShapeDelete Style="{StaticResource StyleIcon}"/>
                        </Button>

                        <Button ToolTip="Move the selected entry downwards."
                                Click="buttonMoveDownClick" Style="{StaticResource styleDisableOnNull}">
                            <Shapes:ShapeNext Style="{StaticResource StyleIcon}"/>
                        </Button>
                    </StackPanel>
                </Grid>
            </TabItem>

            <TabItem Header="About">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" Text="{Binding Source={x:Static lb:MetaData.Version}, StringFormat='Launchbar {0}', Mode=OneTime}"
                               Foreground="DodgerBlue" FontSize="36"/>

                    <TextBlock Grid.Row="1" FontSize="16">
                        <Run Text="Based on RUNit by"/>
                        <Hyperlink NavigateUri="http://www.magister-lex.at">
                            <Run Text="Andreas Hoeller"/>
                        </Hyperlink>
                    </TextBlock>

                    <TextBlock Grid.Row="2" Margin="0,5,0,0" TextWrapping="Wrap">
                            Note: Nearly all icons used in this application are made by
                        <Hyperlink NavigateUri="http://arvidaxelsson.se">Arvid Axelsson</Hyperlink>
                        released under the <Hyperlink NavigateUri="http://creativecommons.org/licenses/by-sa/3.0">
                            Creative Commons Attribution-Share Alike License</Hyperlink>.
                    </TextBlock>

                    <TextBlock Grid.Row="3" Margin="0,5,0,0" Text="Changelog:"/>

                    <TextBox Grid.Row="4" Text="{Binding Source={x:Static Properties:Resources.Changelog}, Mode=OneTime}"
                             TextWrapping="Wrap" IsReadOnly="True" VerticalScrollBarVisibility="Auto"/>
                </Grid>
            </TabItem>
        </TabControl>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <FrameworkElement.Resources>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                    <Setter Property="Margin" Value="3"/>
                    <Setter Property="MinWidth" Value="75"/>
                </Style>
            </FrameworkElement.Resources>

            <Button Grid.Column="0" Click="buttonShutdownClick">
                <TextBlock Text="Exit Launchbar" Foreground="DarkRed"/>
            </Button>

            <Button Grid.Column="2" Click="buttonOkClick" IsDefault="True">
                <TextBlock Text="OK"/>
            </Button>

            <Button Grid.Column="3" Click="buttonCancelClick" IsCancel="True">
                <TextBlock Text="Cancel"/>
            </Button>

            <Button Grid.Column="4" Click="buttonApplyClick">
                <TextBlock Text="Apply"/>
            </Button>
        </Grid>
    </Grid>
</Window>